var app = getApp();

Page({
  data: {
    currentIndex: 1,
    currentResult: 0,
    joinCurrentResult: 0,
    // 团队列表
    myTeamList: [],
    // 团队列表
    joinTeamList: [],
    loadingBoo: !0,
    moreBooTwo: !0,
    moreBooOne: !0,
    tablistIndex: 1,
    tablistIndex1: 1,
    tabshow: !0,
    tabshow1: !1,
    tabshow2: !0,
    tabshow12: !1
  },
  teaminfo(e) {
    var that = this
    var t_id = e.currentTarget.dataset.t_id
    var teamname = e.currentTarget.dataset.teamname
    var teampic = e.currentTarget.dataset.teampic
    var teamtext = e.currentTarget.dataset.teamtext
    var z_name = e.currentTarget.dataset.z_name
    var z_thumbs = e.currentTarget.dataset.z_thumbs
    var zid = e.currentTarget.dataset.zid
    var yao_type = e.currentTarget.dataset.yao_type
    var teamtext = e.currentTarget.dataset.teamtext
    if (yao_type == 3) {
      wx.showToast({
        title: '申请中，等待通过',
        icon: 'none'
      })
    } else {
      wx.navigateTo({
        url: '/hyb_yl/backstageTeam/pages/teamDetails/teamDetails?t_id=' + t_id + '&teampic=' + teampic + '&zid=' + zid + '&teamname=' + teamname + '&z_thumbs=' + z_thumbs + '&z_name=' + z_name + '&teamtext=' + teamtext,
      })
    }
  },
  tapFun: function(t) {
    var a = this;
    this.setData({
      currentIndex: t.target.dataset.current,
      loadingBoo: !0,
      noneFlag: !1,
      typeFlag: !1
    }), 2 == a.data.currentIndex ? (a.setData({
      moreBooTwo: !0,
      joinCurrentResult: 0
    }), a.getJointeamList(a)) : (a.setData({
      moreBooOne: !0,
      currentResult: 0
    }));
  },
  tapFun1: function(t) {
    var a = this;
    console.log(t.target.dataset.current), this.setData({
      tablistIndex: t.target.dataset.current,
      loadingBoo: !0,
      noneFlag: !1,
      typeFlag: !1,
      moreBooOne: !0
    }), 1 == t.target.dataset.current ? (this.setData({
      tabshow: !0,
      tabshow1: !1,
      moreBooOne: !0,
      currentResult: 0
    }), a.getTeamList(a)) : 2 == t.target.dataset.current && (this.setData({
      tabshow: !1,
      tabshow1: !0,
      moreBooOne: !0,
      currentResult: 0
    }), a.getTeamList(a));
  },
  tapFun2: function(t) {
    var a = this;
    console.log(t.target.dataset.current), this.setData({
      tablistIndex1: t.target.dataset.current,
      loadingBoo: !0,
      noneFlag: !1,
      typeFlag: !1,
      moreBooTwo: !0
    }), 1 == t.target.dataset.current ? (this.setData({
      tabshow2: !0,
      tabshow12: !1,
      moreBooTwo: !0,
      joinCurrentResult: 0
    }), a.getJointeamList(a)) : 2 == t.target.dataset.current && (this.setData({
      tabshow2: !1,
      tabshow12: !0,
      moreBooTwo: !0,
      joinCurrentResult: 0
    }), a.getJointeamList(a));
  },
  onLoad: function(t) {
    var zid = t.zid
    this.setData({
      jobType: t.jobType || "",
      token: wx.getStorageSync("log"),
      zid: zid
    });
  },
  onReady: function() {},
  onShow: function() {
    //查询我创建的线上科室
    var that = this
    var zid = that.data.zid
    var indx = that.data.tablistIndex
    if (indx == 2) {
      var teamtype = 1
    } else {
      var teamtype = 0
    }
    console.log(teamtype)
    app.util.request({
      'url': 'entry/wxapp/studio.yihu',
      data: {
        zid: zid,
        teamtype: teamtype,
      },
      success: function(res) {
        console.log(res)
        that.setData({
          myTeamList: res.data.data
        })
      }
    })
  },
  getMoreMyTeam: function(t) {
    var that = this(t = this).data.moreBooOne && this.data.loadingBoo && (t.setData({
      loadingBoo: !1
    }), t.getTeamList(t));
  },
  getMoreOtherTeam: function(t) {
    (t = this).data.moreBooTwo && this.data.loadingBoo && (t.setData({
      loadingBoo: !1
    }), t.getJointeamList(t));
  },



  join: function() {
    wx.navigateTo({
      url: "/hyb_yl/backstageTeam/pages/teamListJoin/teamListJoin"
    });
  },
  getTeamList: function(a) {
    var that = this
    var zid = a.options.zid
    var index = a.__viewData__.tablistIndex
    if (index == 2) {
      app.util.request({
        'url': 'entry/wxapp/studio.yihu',
        data: {
          zid: zid,
          teamtype: 1,
        },
        success: function(res) {
          console.log(res)
          that.setData({
            myTeamList: res.data.data
          })
        }
      })
    } else {
      app.util.request({
        'url': 'entry/wxapp/studio.yihu',
        data: {
          zid: zid,
          teamtype: 0,
        },
        success: function(res) {
          console.log(res)
          that.setData({
            myTeamList: res.data.data
          })
        }
      })
    }
  },
  getJointeamList: function(a) {
    var that = this
    var zid = a.options.zid
    var tablistIndex1 = that.data.tablistIndex1
    app.util.request({
      'url': 'entry/wxapp/studio.myjoinstudio',
      data: {
        zid: zid,
        teamtype: tablistIndex1,
      },
      'cachetime': '30',
      success: function(res) {
        console.log(res)
        that.setData({
          joinTeamList: res.data
        })
      }
    })
  }
});